<template>
  <div class="header">
    <div class="header-content">
      <div>
        <a class="jump-home" @click="jumpToHome">
          <img src="../../assets/img/other/keTangLogo.png" alt="ha">
        </a>
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
                 v-show="role==='student'">
          <el-menu-item index="1">我的课堂</el-menu-item>
        </el-menu>
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
                 v-show="role==='teacher'">
          <el-menu-item index="1">我的课堂</el-menu-item>
          <el-menu-item index="2">备课区</el-menu-item>
          <el-menu-item index="3">虚拟教研室</el-menu-item>
        </el-menu>
      </div>
      <div class="user-center">
        <span title="任务管理" class="task">
          <i class="el-icon-s-claim"></i>
        </span>
        <el-popover
            popper-class="area_popper"
            placement="bottom-start"
            trigger="click"
        >
          <div class="notice">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="全部" name="first"></el-tab-pane>
              <el-tab-pane label="教学活动" name="second"></el-tab-pane>
              <el-tab-pane label="教务通知" name="third"></el-tab-pane>
              <el-tab-pane label="系统通知" name="fourth"></el-tab-pane>
            </el-tabs>
            <div class="notice-foot">
              <div class="btn">
                <i class="el-icon-check"></i>
                <el-button type="text">一键标为已读</el-button>
              </div>
              <div class="btn">
                <i class="el-icon-view"></i>
                <el-button type="text">查看全部</el-button>
              </div>
            </div>
          </div>
          <div slot="reference"><i class="el-icon-bell new"></i></div>
        </el-popover>
        <el-dropdown @command="handleCommand" trigger="click">
          <div><img src="../../assets/img/other/user.png" alt="ha"></div>
          <el-dropdown-menu>
            <el-dropdown-item command="a"><i class="el-icon-bank-card"></i>开通VIP</el-dropdown-item>
            <el-dropdown-item command="b"><i class="el-icon-link"></i>机构用户认证</el-dropdown-item>
            <el-dropdown-item command="c"><i class="el-icon-setting"></i> 个人设置</el-dropdown-item>
            <el-dropdown-item command="d"><i class="el-icon-right"></i> 退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      activeName: 'first',
      activeIndex: '1',
    };
  },
  methods: {
    handleSelect(key) {
      this.$emit('changeMenu', key)
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    handleCommand(command) {
      if (command === "d") {
        localStorage.removeItem("token")
        localStorage.removeItem("role")
        this.jumpToHome()
      }
    },
    jumpToHome() {
      this.$router.push('/bigPage/homepage')
    },

  },
  components: {},
  props: ['role'],
}
</script>

<style scoped>
.header {
  height: 80px;
  width: 100%;
  margin-bottom: 16px;
  box-sizing: border-box;
  box-shadow: 0 0 10px #ccc;
}

.header-content {
  position: fixed;
  background-color: #fff;
  z-index: 999;
  top: 0;
  left: 0;
  height: 80px;
  width: 100%;
  padding: 0 40px;
  min-width: 900px;
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 0 0 #dfdfdf;
}

.jump-home {
  cursor: pointer;
}

.jump-home img {
  max-height: 36px;
  border: none;
}

.user-center {
  display: flex;
  align-items: center;
}

.task {
  cursor: pointer;
  margin-right: 18px;
  position: relative;
}

.task i {
  font-size: 30px;
}

.new {
  font-size: 30px;
  margin-right: 18px;
}

.user-center img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

::v-deep .el-menu-item {
  font-size: 21px;
  padding: 0;
}

::v-deep .el-menu--horizontal > .el-menu-item.is-active {
  border-bottom: 3px solid #409EFF;
}

::v-deep .el-menu--horizontal > .el-menu-item {
  padding: 10px 0;
  margin: 0 35px;
  height: 80px;
}

::v-deep .el-menu.el-menu--horizontal {
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-width: 0;
}

.notice {
  margin-top: 10px;
  padding: 0 45px;
}

::v-deep .el-tabs__item {
  font-size: 21px;
  padding: 0 25px;
  height: 50px;
}

::v-deep .el-tabs__active-bar {
  height: 3px;
}

.notice-foot {
  margin-top: 30px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: #4285f4;
  line-height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn {
  font-size: 18px;
  cursor: pointer;
  width: 50%;
  height: 50px;
  line-height: 50px;
}

.btn i {
  margin-right: 8px;
}

.btn > .el-button {
  font-size: 18px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}

.el-icon-arrow-down {
  font-size: 12px;
}

::v-deep .el-dropdown-menu__item {
  font-size: 16px;
  line-height: 55px;
}


</style>
